﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;
using System.IO;

namespace zp.mk.ImageClick
{
    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }


        private void btnOpemDirectory_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                DirectoryInfo di = new DirectoryInfo(fbd.SelectedPath);
                FileInfo[] fi = di.GetFiles();

                foreach (FileInfo file in fi)
                {

                    Image ti = new Image();
                    //ti.FindName(file.FullName);
                    ti.Source = new BitmapImage(new Uri(file.FullName));
                    ti.Margin = new Thickness(5);
                    ti.Stretch = Stretch.None;
                    ti.MouseLeftButtonUp += ti_MouseLeftButtonUp;
                    wPanel.Children.Add(ti);
                }
            }
        }

        void ti_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Image ti = (Image) sender;
            imgShow.Source = ti.Source;
            imgShow.Stretch = Stretch.None;
        }

    }
}
